<template>
  <t-image-viewer v-if="!store.isMobileType" v-model:visible="ImgVisible" :images="[urls + props.info.value]">
  </t-image-viewer>
  <van-image-preview :show-index="false" v-else v-model:show="ImgVisible" :images="[urls + props.info.value]">
  </van-image-preview>
  <div class="outline-parent">
    <img
      class="outline-parent-bg"
      v-if="
        (props.info.remarks || props.info.subTitle) && (props.info.value || (props.info.video && props.info.video.url))
      "
      :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle2Bg.webp'"
      alt=""
    />
    <img class="outline-parent-bg2" v-else :src="publicUrls + 'free/style2/Auxiliaryoutlinestyle2-1Bg.webp'" alt="" />
    <div
      class="outline border-hover-style"
      v-if="
        (props.info.remarks || props.info.subTitle) && (props.info.value || (props.info.video && props.info.video.url))
      "
    >
      <div class="content-item">
        <div
          class="audio-box"
          :class="isPlay && 'audio-rotate'"
          v-if="props.info.audio && props.info.audio.url"
          @click="audioplay(true)"
        >
          <i class="doorIcon">&#xe688;</i>
        </div>
        <audio
          v-if="props.info.audio && props.info.audio.url"
          :src="urls + props.info.audio.url"
          ref="audioRef"
        ></audio>
        <div class="medium">
          <img
            v-if="props.info.value && !(props.info.video && props.info.video.url)"
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
            alt=""
          />
          <videoview @click="audioplay(false)" :info="props.info"></videoview>
        </div>
      </div>
      <div class="outline-right">
        <p class="outline-title" :class="store.isMobileType && 'titleLineHeight'">{{ props.info.text }}</p>
        <p class="outline-subTitle" v-if="props.info.subTitle">
          {{ props.info.subTitle }}
        </p>
        <TextMax
          v-if="props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :infoData="props.info"
          :row="props.info.subTitle ? 5 : 7"
        ></TextMax>
      </div>
    </div>

    <div
      class="outline outline2 border-hover-style"
      :class="!(props.info.audio && props.info.audio.url) && 'outlinePad'"
      v-else
    >
      <div
        class="audio-box"
        :class="isPlay && 'audio-rotate'"
        v-if="props.info.audio && props.info.audio.url"
        @click="audioplay(true)"
      >
        <i class="doorIcon">&#xe688;</i>
      </div>
      <audio v-if="props.info.audio && props.info.audio.url" :src="urls + props.info.audio.url" ref="audioRef"></audio>
      <div class="outline-right">
        <p class="outline-title">{{ props.info.text }}</p>
        <p class="outline-subTitle" v-if="props.info.subTitle">
          {{ props.info.subTitle }}
        </p>
        <TextMax
          v-if="props.domShow"
          :data="props.info.remarks"
          :title="props.info.text"
          :infoData="props.info"
          :row="props.info.subTitle ? 4 : 6"
        ></TextMax>
        <div class="medium">
          <img
            v-if="props.info.value && !(props.info.video && props.info.video.url)"
            class="outline-cover"
            @click="ImgVisible = true"
            :src="urls + props.info.value + '?imageView2/3/w/898/h/460/format/webp'"
            alt=""
          />
          <videoview @click="audioplay(false)" :info="props.info"></videoview>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
export default defineComponent({
  name: 'free2Style2',
});
</script>

<script setup lang="ts">
import { publicUrls } from '@/utils/minxin';
import { useProjectStore } from '@/store';
import { urls } from '@/utils/request/upload';
import { defineComponent, ref, watch } from 'vue';
import TextMax from '@/freeComponents/textMode/TextMax.vue';
import videoview from './../../../videoDialog/videoview.vue';

const props = defineProps({
  info: {
    type: Object,
  },
  domShow: {
    type: Boolean,
  },
});

const ImgVisible = ref(false);
const audioRef = ref(null);
const videoRef = ref(null);
const isPlay = ref(false);
const flag = ref(true);
const store = useProjectStore();
const audioplay = (flag: boolean = true) => {
  if (audioRef.value.paused && flag) {
    audioRef.value.play();
    if (videoRef.value) {
      videoRef.value.pause();
    }

    isPlay.value = true;
  } else {
    audioRef.value.pause();
    isPlay.value = false;
  }
};

const videoplay = () => {
  if (videoRef.value.paused) {
    videoRef.value.play();
    if (audioRef.value) {
      audioRef.value.pause();
    }

    isPlay.value = false;
  } else {
    videoRef.value.pause();
    isPlay.value = true;
  }
};
</script>

<style scoped lang="less">
.outline-parent {
  position: relative;
  -webkit-box-reflect: below 70% linear-gradient(transparent, rgba(0, 0, 0, 0.15));
}
.outline-parent-bg {
  width: 760px;
  height: 360px;
  margin-top: 78px;
  margin-right: 10px;
}
.outline {
  position: absolute;
  // top: 240px;
  top: 80px;
  left: 0;
  z-index: 20;
  width: 760px;
  height: 360px;
  padding: 20px 66px 20px 20px;
  display: flex;
}

.outline-right {
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
  .titleLineHeight {
    line-height: 44px !important;
  }
  .outline-title {
    height: 40px;
    font-family: SourceHanSerifCN-Bold;
    font-size: 20px;
    line-height: 34px;
    color: #212326;
    text-align: center;
    margin-bottom: 34px;
    flex-shrink: 0;
  }
  .outline-subTitle {
    width: 100%;
    margin-bottom: 20px;
    font-family: SourceHanSerifCN;
    font-size: 18px;
    color: #212326;
    line-height: 28px;
    text-align: justify;
    opacity: 80%;
  }
}

.content-item {
  position: relative;
  width: 319px;
  height: 318px;
  flex-shrink: 0;
  margin-left: 1px;
  margin-right: 22px;
}
.medium {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 50%;
  border: 1px solid #212326;
  overflow: hidden;

  .mask-layer {
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    position: absolute;
    top: 50%;
    transform: translate(0%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    .round {
      width: 40px;
      height: 40px;
      border-radius: 50%;
      border: 2px solid rgba(255, 245, 228, 1);
      text-align: center;
      .freeIcon {
        font-size: 24px;
        line-height: 38px;
        color: rgba(255, 245, 228, 1);
      }
    }
  }
  .outline-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    object-position: top;
  }
}

.audio-rotate {
  animation: audio-rotate 3s linear infinite;
  @keyframes audio-rotate {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }
}

.audio-box {
  position: absolute;
  bottom: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #ffdc76;
  border-radius: 50%;
  box-shadow: 0px 2px 4px #0000001a;
  .doorIcon {
    font-size: 24px;
    color: #5b8c87;
  }
  z-index: 22;
}

::v-deep .van-text-ellipsis {
  font-family: SourceHanSerifCN-Medium !important;
  font-size: 16px !important;
  color: rgba(33, 35, 38, 0.6) !important;
  line-height: 32px !important;
}
::v-deep .van-text-ellipsis__action::before {
  color: #ffdc76 !important;
  font-weight: 400 !important;
  text-decoration-line: underline;
}
::v-deep .t-popup__content {
  background: #5b8c87;
  box-shadow: none;
  padding: 4px 10px;
  font-size: 14px !important;
  line-height: 22px;
  color: #fff;
  box-shadow: 0px 5px 5px -3px rgba(0, 0, 0, 0.1), 0px 8px 10px 1px rgba(0, 0, 0, 0.06),
    0px 3px 14px 2px rgba(0, 0, 0, 0.05);
}
::v-deep .t-popup__arrow::before {
  background: #5b8c87;
  border: none;
  box-shadow: none !important;
}

.outline-parent-bg2 {
  width: 596px;
  height: 360px;
  margin-top: 78px;
}
.outlinePad {
  padding-left: 140px !important;
}

.outline2 {
  width: 596px !important;
  height: 360px !important;
  padding: 50px 96px 58px 64px;
  align-items: center;
  .audio-box {
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    margin-right: 28px;
    flex-shrink: 0;
  }
  .outline-title {
    background: #ffdc76;
    border-top: 2px solid #212326;
    border-bottom: 2px solid #212326;
    margin-bottom: 20px !important;
  }
  .outline-subTitle {
    margin-bottom: 16px;
  }
  .medium {
    border-radius: 0% !important;
    border: none;
  }
  .outline-cover {
    max-height: 200px;
    object-position: top;
  }
}
</style>
